package org.gangcai.mac.shop.bean;


import org.gangcai.mac.shop.entity.MultipleItem;

import java.util.ArrayList;
import java.util.List;

import org.gangcai.mac.shop.entity.Status;

/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class DataServer {

    private static final String HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK = "https://avatars1.githubusercontent.com/u/7698209?v=3&s=460";
    private static final String CYM_CHAD = "CymChad";
    private static final String CHAY_CHAN = "ChayChan";

    private DataServer() {
    }

    public static List<Status> getSampleData(int lenth) {
        List<Status> list = new ArrayList<>();
        for (int i = 0; i < lenth; i++) {
            Status status = new Status();
            status.setUserName( "Chad" + i );
            status.setCreatedAt( "04/05/" + i );
            status.setRetweet( i % 2 == 0 );
            status.setUserAvatar( "https://avatars1.githubusercontent.com/u/7698209?v=3&s=460" );
            status.setText( "BaseRecyclerViewAdpaterHelper https://www.recyclerview.org" );
            list.add( status );
        }
        return list;
    }

    public static List<Status> addData(List list, int dataSize) {
        for (int i = 0; i < dataSize; i++) {
            Status status = new Status();
            status.setUserName( "Chad" + i );
            status.setCreatedAt( "04/05/" + i );
            status.setRetweet( i % 2 == 0 );
            status.setUserAvatar( "https://avatars1.githubusercontent.com/u/7698209?v=3&s=460" );
            status.setText( "Powerful and flexible RecyclerAdapter https://github.com/CymChad/BaseRecyclerViewAdapterHelper" );
            list.add( status );
        }

        return list;
    }

    public static List<MySection> getSampleDataForHome(HomeIndexBean.HomeBean homebean) {
        List<MySection> list = new ArrayList<>();
        List<HomeIndexBean.Menu> menu_list = homebean.getMenu_list();
        list.add( new MySection( true, "Menu", false ) );
        for (HomeIndexBean.Menu menu : menu_list) {
            list.add( new MySection( new Video( "mobile/" + menu.getMenu_img(), menu.getMenu_name() ) ) );
        }
        List<HomeIndexBean.ShopCell> recommend_goods = homebean.getRecommend_goods();
        list.add( new MySection( true, "精品推荐", true ) );
        for (HomeIndexBean.ShopCell shopCell : recommend_goods) {
            list.add( new MySection( new Video( shopCell.getThumb(), shopCell.getGoods_name() ) ) );
        }
        List<HomeIndexBean.Floor> floor_list = homebean.getFloor_list();
        for (HomeIndexBean.Floor floor : floor_list) {
            list.add( new MySection( true, floor.getFloor_name(), true ) );
            for (HomeIndexBean.ShopCell shopCell : floor.getGoods_list()) {
                list.add( new MySection( new Video( shopCell.getThumb(), shopCell.getGoods_name() ) ) );
            }
        }
        List<HomeIndexBean.ShopCell> goodslist = homebean.getGoodslist();
        list.add( new MySection( true, "--精品推荐--", true ) );
        for (HomeIndexBean.ShopCell shopCell : goodslist) {
            list.add( new MySection( new Video( shopCell.getThumb(), shopCell.getGoods_name() ) ) );
        }
        return list;

    }

    public static List<MySection> getSampleData() {
        List<MySection> list = new ArrayList<>();
        list.add( new MySection( true, "Section 1", true ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( true, "Section 2", false ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( true, "Section 3", false ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( true, "Section 4", false ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( true, "Section 5", false ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        list.add( new MySection( new Video( HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD ) ) );
        return list;
    }

    public static List<String> getStrData() {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            String str = HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK;
            if (i % 2 == 0) {
                str = CYM_CHAD;
            }
            list.add( str );
        }
        return list;
    }

    public static List<MultipleItem> getMultipleItemData() {
        List<MultipleItem> list = new ArrayList<>();
        for (int i = 0; i <= 4; i++) {
            list.add( new MultipleItem( MultipleItem.IMG, MultipleItem.IMG_SPAN_SIZE ) );
            list.add( new MultipleItem( MultipleItem.TEXT, MultipleItem.TEXT_SPAN_SIZE, CYM_CHAD ) );
            list.add( new MultipleItem( MultipleItem.IMG_TEXT, MultipleItem.IMG_TEXT_SPAN_SIZE ) );
            list.add( new MultipleItem( MultipleItem.IMG_TEXT, MultipleItem.IMG_TEXT_SPAN_SIZE_MIN ) );
            list.add( new MultipleItem( MultipleItem.IMG_TEXT, MultipleItem.IMG_TEXT_SPAN_SIZE_MIN ) );
        }

        return list;
    }

    public static List<MultipleItem> getMultipleItemData(HomeIndexBean.HomeBean homebean) {
        List<MultipleItem> list = new ArrayList<>();
//        List<HomeIndexBean.Menu> menu_list = homebean.getMenu_list();
//        for(HomeIndexBean.Menu menu : menu_list){
//            list.add(new MultipleItem(MultipleItem.IMG_TEXT, MultipleItem.IMG_SPAN_SIZE));
////            list.add(new MultipleItem(new Video("mobile/"+menu.getMenu_img(), menu.getMenu_name())));
//        }
        List<HomeIndexBean.ShopCell> recommend_goods = homebean.getRecommend_goods();
//        list.add(new MySection(true, "精品推荐", true));
        MultipleItem recommendTItem = new MultipleItem( MultipleItem.TEXT, MultipleItem.IMG_TEXT_SPAN_SIZE_MAX, "精品推荐" );
        list.add( recommendTItem );
        int recommendNum = 0;
        for (HomeIndexBean.ShopCell shopCell : recommend_goods) {
            if (recommendNum < 3) {
                MultipleItem recommendItem = new MultipleItem( MultipleItem.IMG_TEXT, MultipleItem.IMG_TEXT_SPAN_SIZE_MIN );
                recommendItem.setGoods_id( shopCell.getGoods_id() );
                recommendItem.setContent( shopCell.getGoods_name() );
                recommendItem.setThumb( shopCell.getThumb() );
                list.add( recommendItem );
                recommendNum++;
            }
        }
        List<HomeIndexBean.Floor> floor_list = homebean.getFloor_list();
        for (int i = 0; i < floor_list.size(); i++) {
            HomeIndexBean.Floor floor = floor_list.get( i );
            MultipleItem floorTItem = new MultipleItem( MultipleItem.TEXT, MultipleItem.IMG_TEXT_SPAN_SIZE_MAX, floor.getFloor_name() );
            floorTItem.setCat_id( floor.getCat_id() );
            list.add( floorTItem );
//            list.add(new MultipleItem(MultipleItem.IMG_TEXT, MultipleItem.IMG_TEXT_SPAN_SIZE_MIN));
//            list.add(new MySection(true, floor.getFloor_name(), true));
            for (HomeIndexBean.ShopCell shopCell : floor.getGoods_list()) {
                MultipleItem floorItem = new MultipleItem( (i == 0) ? MultipleItem.IMG_TEXT : MultipleItem.IMG, (i == 0) ? MultipleItem.IMG_TEXT_SPAN_SIZE_MIN : MultipleItem.TEXT_SPAN_SIZE );
                floorItem.setGoods_id( shopCell.getGoods_id() );
                floorItem.setContent( shopCell.getGoods_name() );
                floorItem.setThumb( shopCell.getThumb() );
                list.add( floorItem );
//                list.add(new MySection(new Video(shopCell.getThumb(), shopCell.getGoods_name())));
            }
        }
        List<HomeIndexBean.ShopCell> goodslist = homebean.getGoodslist();
//        list.add(new MySection(true, "--精品推荐--", true));
        MultipleItem shopTItem = new MultipleItem( MultipleItem.TEXT, MultipleItem.IMG_TEXT_SPAN_SIZE_MAX, "———— 精品推荐 ————" );
        list.add( shopTItem );
        for (HomeIndexBean.ShopCell shopCell : goodslist) {
            MultipleItem goodItem = new MultipleItem( MultipleItem.IMG, MultipleItem.TEXT_SPAN_SIZE );
            goodItem.setGoods_id( shopCell.getGoods_id() );
            goodItem.setContent( shopCell.getGoods_name() );
            goodItem.setThumb( shopCell.getThumb() );
            list.add( goodItem );
//            list.add(new MySection(new Video(shopCell.getThumb(), shopCell.getGoods_name())));
        }
        return list;

    }

    public static List<NormalMultipleEntity> getNormalMultipleEntities() {
        List<NormalMultipleEntity> list = new ArrayList<>();
        for (int i = 0; i <= 4; i++) {
            list.add( new NormalMultipleEntity( NormalMultipleEntity.SINGLE_IMG ) );
            list.add( new NormalMultipleEntity( NormalMultipleEntity.SINGLE_TEXT, CHAY_CHAN ) );
            list.add( new NormalMultipleEntity( NormalMultipleEntity.TEXT_IMG, CHAY_CHAN ) );
            list.add( new NormalMultipleEntity( NormalMultipleEntity.TEXT_IMG, CYM_CHAD ) );
            list.add( new NormalMultipleEntity( NormalMultipleEntity.TEXT_IMG, CHAY_CHAN ) );
        }
        return list;
    }

//    public static List<MultipleItem> getMultipleChildView() {
//        List<MultipleItem> list = new ArrayList<>();
//        for (int i = 0; i <= 4; i++) {
//            list.add(new ClickEntity(ClickEntity.CLICK_ITEM_VIEW, MultipleItem.TEXT_SPAN_SIZE, CYM_CHAD));
//            list.add(new MultipleItem(MultipleItem.IMG, MultipleItem.BIG_IMG_SPAN_SIZE));
//            list.add(new MultipleItem(MultipleItem.IMG, MultipleItem.IMG_SPAN_SIZE));
//            list.add(new MultipleItem(MultipleItem.IMG, MultipleItem.IMG_SPAN_SIZE));
//            list.add(new MultipleItem(MultipleItem.IMG, MultipleItem.IMG_SPAN_SIZE));
//        }
//
//        return list;
//    }


}
